﻿@{
    ViewBag.Title = "页面权限列表";
    Layout = "~/Views/Shared/InfoMaste.cshtml";

}
<script type="text/javascript">
    function doSearch() {
        $('#tg').treegrid('load', {
        });
    }

    //新增数据
    function addPageUrlInfo() {
        $('#dlg').dialog('open').dialog('setTitle', '新增');
        $('#fm').form('clear');
        $('#LevelID').combotree({
            url: "/SystemSet/GetPageUrlInfoJson",
            editable: false,
            valueField: 'ID',
            textField: 'UrlName'
        });
        url = '/SystemSet/AddPageUrlInfo';
    }
    //编辑数据
    function editPageUrlInfo() {
        var row = $('#tg').treegrid('getSelected');
        if (!row) {
            Helper.Show("请选择数据编辑!");
            return false;
        }
        $('#dlg').dialog('open').dialog('setTitle', '编辑');
        $('#LevelID').combotree({
            url: "/SystemSet/GetPageUrlInfoJson",
            editable: false,
            valueField: 'ID',
            textField: 'UrlName'
        });
        $('#fm').form('load', row);
        url = '/SystemSet/EditPageUrlInfo';
    }

    function pageUrlSaveData() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                $.messager.show({
                    title: '消息提示',
                    msg: json.Msg
                });
                if (json.Success) {
                    $('#dlg').dialog('close');
                    doSearch();
                }
            }
        });
    }

    function delPageUrlInfo() {
        var row = $('#tg').treegrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/SystemSet/DelPageUrlInfo", { id: row.ID }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    doSearch();
                }
            });
        });
    }
 
</script>
<div id="tb" style="padding: 3px; height: auto;">
    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addPageUrlInfo()">新增</a>
    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editPageUrlInfo()">编辑</a>
    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" onclick="delPageUrlInfo()">删除</a>
</div>
<table id="tg" title="页面管理列表" toolbar="#tb" class="easyui-treegrid" style="width: auto; height: auto"
       data-options="
				url: '/SystemSet/GetPageUrlTreeView',
				method: 'post',
				rownumbers: true,
				idField: 'ID',
				treeField: 'UrlName'
			">
    <thead>
        <tr>
            <th data-options="field:'ID'" width="100"> 操作</th>
            <th data-options="field:'UrlName'" width="200">姓名</th>
            <th data-options="field:'Url'" align="right" width="250">路径</th>
            <th data-options="field:'Icon'" align="right" width="100">图标</th>
            <th data-options="field:'LevelID'" align="right" width="100">所属父级</th>
            <th data-options="field:'Sort'" align="right" width="100">排序</th>
        </tr>
    </thead>
</table>

<div id="dlg" class="easyui-dialog" title="新增" data-options="iconCls:'icon-save'"
     closed="true" style="width: 450px; height: 380px; padding: 10px 20px;" buttons="#dlg-buttons" modal="true">
    <form id="fm" method="post" novalidate>
        <div class="fitem">
            <label>
                ID :
            </label>
            <input class="easyui-validatebox textbox" name="ID" data-options="required:true"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                页面名称 :
            </label>
            <input class="easyui-validatebox textbox" name="UrlName" data-options="required:true"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                所属父级 :
            </label>
            <input class="easyui-combobox" id="LevelID" name="LevelID" data-options="required:true" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                图标 :
            </label>
            <input class="easyui-validatebox textbox" name="Icon" data-options="required:true"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                路径 :
            </label>
            <input class="easyui-textbox" name="Url" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                排序 :
            </label>
            <input class="easyui-validatebox textbox" name="Sort" data-options="required:true"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="pageUrlSaveData()">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>
